package admin.server.feign;

import admin.server.config.FeignConfig;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestParam;
import admin.common.domain.rsp.EmployeesRsp;
import admin.common.domain.rsp.R;
import admin.common.domain.rsp.UserInfoRsp;
import admin.common.domain.rsp.UsersRsp;

/**
 * @author zgb
 * @date 2024-02-29 18:24
 * @description TODO
 */
//不用走网关
@FeignClient(name = "FeishuJavaService",path ="${services.auth.contextPath}/feishuJava",url = "${services.auth.ip}:${services.auth.port}",configuration = FeignConfig.class)
public interface FeishuJavaFeign {


    @Operation(summary = "自建应用获取 tenant_access_token")
    @GetMapping("tenantAccessToken")
    public String tenantAccessToken() ;

    @Operation(summary = "自建应用获取 app_access_token")
    @GetMapping("appAccessToken")
    public String appAccessToken();


    @Operation(summary = "获取 user_access_token")
    @GetMapping("userAccessToken")
    public String  userAccessToken(@RequestParam("code") String code);

    @Operation(summary = "获取登录用户信息:请求头Authorization:Bearer userAccessToken，feign已配置RequestInterceptor会把头Authorization传递到RequestTemplate")
    @GetMapping("userInfo")
    public R<UserInfoRsp> userInfo(@RequestHeader("Authorization") String authorization);

    @Operation(summary = "获取单个用户信息:请求头Authorization:Bearer userAccessToken，feign已配置RequestInterceptor会把头Authorization传递到RequestTemplate,飞书open_id=飞书user_id")
    @GetMapping("users/{userId}")
    public R<UsersRsp> users(@PathVariable("userId") String userId, @RequestHeader("Authorization") String authorization) ;



    @Operation(summary = "批量获取员工花名册信息:请求头Authorization:Bearer tenantAccessToken，feign已配置RequestInterceptor会把头Authorization传递到RequestTemplate")
    @GetMapping("employees")
    public R<EmployeesRsp> employees(@RequestHeader("Authorization") String authorization, @RequestParam(value = "pageToken", required = false) String pageToken) ;




}
